import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login/',
    method: 'POST',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/user_info/',
    method: 'GET',
    params: { token }
  })
}

export function logout(data) {
  return request({
    url: '/user/logout/',
    method: 'POST',
    data
  })
}

export function getUsers(query) {
  return request({
    url: '/user/user/',
    method: 'GET',
    params: query
  })
}

export function getUserList() {
  return request({
    url: '/user/user_list/',
    method: 'GET'
  })
}

export function addUser(userInfo) {
  return request({
    url: '/user/user/',
    method: 'POST',
    data: userInfo
  })
}

export function updateUser(userInfo) {
  return request({
    url: `/user/user/${userInfo.id}/`,
    method: 'PATCH',
    data: userInfo
  })
}

export function delUser(user_id) {
  return request({
    url: `/user/user/${user_id}/`,
    method: 'DELETE',
  })
}

export function updatePassword(userInfo) {
  return request({
    url: '/user/password/',
    method: 'POST',
    data: userInfo
  })
}

export function userLogList() {
  return request({
    url: '/user/user_log/',
    method: 'GET',
  })
}

export function updatePasswd(pwdInfo) {
  return request({
    url: '/user/passwd/',
    method: 'POST',
    data: pwdInfo
  })
}